import { ProFormOptions } from '@/components/pro-form/type'
import { OrgModel } from '@/api/model/org-model'

export const useOrgProForm = () => {
  const [orgForm, resetOrgForm] = useProRef<Partial<OrgModel>>({})

  const orgFormOptions = computed(() => [
    {
      grid: {
        cols: '1'
      },
      columnItemList: [
        {
          formItem: {
            formType: 'input',
            key: 'orgName',
            label: '机构名称',
            rule: {
              required: true,
              message: '请输机构名称',
              trigger: ['input']
            },
            placeholder: '请输入机构名称'
          }
        },
        {
          formItem: {
            formType: 'input',
            key: 'orgCode',
            label: '机构编号',
            rule: {
              required: true,
              message: '请输机构编号',
              trigger: ['input']
            },
            placeholder: '请输入机构编号'
          }
        },
        {
          formItem: {
            formType: 'select',
            key: 'type',
            label: '机构类型',
            rule: {
              required: true,
              message: '请选择机构类型',
              trigger: ['change']
            },
            dictCode: 'ORG_TYPE',
            placeholder: '请选择机构类型'
          }
        },
        {
          formItem: {
            formType: 'select',
            key: 'continent',
            label: '机构所在大洲',
            dictCode: 'ORG_CONTINENT',
            placeholder: '请选择机构所在大洲'
          }
        },
        {
          formItem: {
            formType: 'input',
            key: 'country',
            label: '机构所在国家',
            placeholder: '请输入机构所在国家'
          }
        },
        {
          formItem: {
            formType: 'input',
            key: 'city',
            label: '机构所在城市',
            placeholder: '请输入机构所在城市'
          }
        }
      ]
    }
  ])

  return {
    orgForm,
    orgFormOptions,
    resetOrgForm
  }
}
